package com.zjh.photoshopstudy.app.login;

import com.zjh.photoshopstudy.Model.AppUserEntity;
import com.zjh.photoshopstudy.Utils.SharePreferencesUtils;

public class LoginPresent {
    private LoginActivity mActivity;
    private LoginHttp mHttp;

    public LoginPresent(LoginActivity loginActivity) {
        mActivity = loginActivity;
        mHttp = new LoginHttp();
    }

    protected void login(String username, String password) {
        mHttp.login(new LoginCallBack(), username, password);


    }

    protected class LoginCallBack {
        public void onLoginSuccess(AppUserEntity user) {
            SharePreferencesUtils.saveLoginUser(user,mActivity);
            mActivity.onLoginSuccess();
        }

        public void onLoginFail(String message) {
            mActivity.onLoginFail(message);
        }
    }

}
